package com.ruoyi.zhongchuangauto.service.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.zhongchuangauto.domain.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zhongchuangauto.mapper.OrderMasterMapper;
import com.ruoyi.zhongchuangauto.domain.OrderMaster;
import com.ruoyi.zhongchuangauto.service.IOrderMasterService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 订单主表Service业务层处理
 *
 * @author ruoyi
 * @date 2025-09-18
 */
@Service
@DataSource(DataSourceType.ZHONGCHUANGAUTO)
public class OrderMasterServiceImpl implements IOrderMasterService
{
    @Autowired
    private OrderMasterMapper orderMasterMapper;
    @Autowired
    private RuoYiConfig ruoyiConfig;   // 直接注入

    /**
     * 查询订单主表
     *
     * @param orderId 订单主表主键
     * @return 订单主表
     */
    @Override
    public OrderMaster selectOrderMasterByOrderId(Long orderId)
    {
        return orderMasterMapper.selectOrderMasterByOrderId(orderId);
    }

    /**
     * 查询订单主表列表
     *
     * @param orderMaster 订单主表
     * @return 订单主表
     */
    @Override
    public List<OrderMaster> selectOrderMasterList(OrderMaster orderMaster)
    {
        return orderMasterMapper.selectOrderMasterList(orderMaster);
    }

    /**
     * 新增订单主表
     *
     * @param orderMaster 订单主表
     * @return 结果
     */
    @Override
    public int insertOrderMaster(OrderMaster orderMaster)
    {
        orderMaster.setCreateTime(DateUtils.getNowDate());
        return orderMasterMapper.insertOrderMaster(orderMaster);
    }

    /**
     * 修改订单主表
     *
     * @param orderMaster 订单主表
     * @return 结果
     */
    @Override
    public int updateOrderMaster(OrderMaster orderMaster)
    {
        orderMaster.setUpdateTime(DateUtils.getNowDate());
        return orderMasterMapper.updateOrderMaster(orderMaster);
    }

    /**
     * 批量删除订单主表
     *
     * @param orderIds 需要删除的订单主表主键
     * @return 结果
     */
    @Override
    public int deleteOrderMasterByOrderIds(Long[] orderIds)
    {
        return orderMasterMapper.deleteOrderMasterByOrderIds(orderIds);
    }

    /**
     * 删除订单主表信息
     *
     * @param orderId 订单主表主键
     * @return 结果
     */
    @Override
    public int deleteOrderMasterByOrderId(Long orderId)
    {
        return orderMasterMapper.deleteOrderMasterByOrderId(orderId);
    }

}
